﻿using KinonekoSoftware.CodariaDB.Runtimes.IO;

namespace KinonekoSoftware.CodariaDB.Runtimes.Abstractions
{
    public interface IRepository : IObjectPool
    {
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        RepositoryCache Snapshot();

        /// <summary>
        /// 
        /// </summary>
        void UpdateProperty();
        
        /// <summary>
        /// 创建一个数据库集合
        /// </summary>
        /// <param name="collectionName">集合名</param>
        /// <typeparam name="T">数据类型</typeparam>
        /// <returns>返回一个数据库集合</returns>
        ILiteCollection<T> Get<T>(string collectionName) where T : class;
        
        /// <summary>
        /// 获取一个值，这个值用于表示数据库中是否有指定集合名的集合存在。
        /// </summary>
        /// <param name="collectionName">集合名</param>
        /// <returns>返回一个值，这个值用于表示数据库中是否有指定集合名的集合存在。如果为true则存在，否则不存在。</returns>
        bool Has(string collectionName);

        /// <summary>
        /// 删除一个数据库集合
        /// </summary>
        /// <param name="collectionName">集合名</param>
        /// <returns>返回操作结果</returns>
        bool Drop(string collectionName);

        /// <summary>
        /// 开始一个事务
        /// </summary>
        /// <returns>返回操作结果</returns>
        bool BeginTransaction();
        
        /// <summary>
        /// 结束一个事务
        /// </summary>
        /// <returns>返回操作结果</returns>
        bool EndTransaction();
        
        /// <summary>
        /// 数据库目录
        /// </summary>
        string Workspace { get; }
        
        /// <summary>
        /// 数据库路径
        /// </summary>
        string DatabaseFileName { get; }
        
        /// <summary>
        /// 
        /// </summary>
        string BackupFileName { get; }
        
        /// <summary>
        /// 数据库缓存路径
        /// </summary>
        string IndexerFileName { get; }
        
        /// <summary>
        /// 
        /// </summary>
        string Name { get; set; }
        
        /// <summary>
        /// 
        /// </summary>
        string Author { get; set; }
        
        /// <summary>
        /// 
        /// </summary>
        string Avatar { get; set; }
        
        /// <summary>
        /// 
        /// </summary>
        string Intro { get; set; }
        
        /// <summary>
        /// 
        /// </summary>
        string ForeignName { get; set; }
        
        /// <summary>
        /// 
        /// </summary>
        int Version { get; }
        
        /// <summary>
        /// 
        /// </summary>
        string DatabaseID { get; }
        
        /// <summary>
        /// 
        /// </summary>
        int DatabaseVersion { get; set; }
        
        /// <summary>
        /// 
        /// </summary>
        DataMode Mode { get; }
        
        IValuePool<string> Strings  { get; }
        IValuePool<int>    Integers { get; }
        IValuePool<bool>   Booleans    { get; }
        RepositoryPropertyManager PropertyManager { get; }
    }
}